<template>
    <div class="student">
        <h2>学生姓名:{{name}}</h2>
        <h2>学生性别:{{sex}}</h2>
        <button @click="sendStudentName">提交学生名</button>
        <button @click="unbind">解绑atGuiGu事件</button>
        <button @click="death">销毁当前student组件的实例VC</button>
    </div>
</template>

<script>

export default {
    name:"Student",
    data(){
        return {
            name:"张三",
            sex:"男",
        }
    },
    methods:{
        sendStudentName(){
            //出发student组件实例身上的atGuiGu事件
            this.$emit("atGuiGu",this.name);
        },
        unbind(){
            this.$off(["atGuiGu"]);//解绑一个或多个自定义事件,参数为空全解绑
        },
        death(){
            this.$destroy();//销毁了当前student组件的实例,自定义事件全都不奏效了
        }
    }
}
</script>

<style scoped>
    .student{
        background-color: orange;
        padding: 5px;
        margin-top: 30px;
    }
</style>